var express = require("express");
var path = require("path");
var app = express();

app.set('port',8880);
app.use(express.static(path.join(__dirname, 'src')));

var home = require("./routes/index");
var index6 = require("./routes/index6");
var ipai = require("./routes/ipai");
var live = require("./routes/live");
var workshow = require("./routes/workshow");
var page = require("./routes/page");
var shop = require("./routes/shop");
var show = require("./routes/show");
var livethree = require("./routes/livethree");
var livetwo = require("./routes/livetwo");
var one = require("./routes/one");
var geren = require("./routes/geren");
var photo = require("./routes/smallphoto");

app.use("/index6", index6.index6);
app.use("/market", home.market);
app.use("/ipai", ipai.ipai);
app.use("/live", live.live);
app.use("/workshow", workshow.workshow);
app.use("/livethree", livethree.livethree);
app.use("/livetwoH", livetwo.livetwo)
app.use("/city/:pageNum", page.page);    //city0的数据
app.use("/market_deta.html", shop.shop);
app.use("/self/:pageNum", page.page1);    //self0的数据
app.use("/data/:pageNum", page.page2);
app.use("/data/live/:pageNum", page.page3);
app.use("/show", show.show);
app.use("/liu/one/", one.one);
app.use("/geren", geren.geren);
app.use("/smallphoto", photo.photo);

//market页面数据
app.get("/marketcity",function(req,res){
	res.sendFile(__dirname + "/data/marketcity.json");
});

//首页index1请求数据
app.get("/first",function(req,res){
	res.sendFile(__dirname + "/data/first.json");
});

//首页index6请求数据
app.get("/aa",function(req,res){
	res.sendFile(__dirname + "/data/aa.json");
});
//图片直播数据
app.get("/liveJson",function(req,res){
	res.sendFile(__dirname + "/data/live.json");
});
app.get("/chuan",function(req,res){
    res.sendFile(__dirname + "/data/xiangce.json");
});
app.get("/gesmall",function(req,res){
    res.sendFile(__dirname + "/data/smallphoto.json");
//  console.log(1);
});
//workshow数据
app.get("/pic",function(req,res){
    res.sendFile(__dirname + "/data/pic.json");
});
//默认显示首页
app.get("/",function(req,res){
	res.sendFile(__dirname + "/src/html/index1.html");
	console.log("a");
});

// 定制404页面
app.use(function(req, res){
    res.type('text/plain');
    res.status(404);
    res.send('404 - Not Found');
});

app.use(function(err, req, res, next){
    console.error(err.stack);
    res.type('text/plain');
    res.status(500);
    res.send('500 - Server Error');
});

app.listen(app.get("port"), function(){
    console.log( '启动成功' );
});

